<?php
/**
 * spsNewsletter Default Controller
 * 
 * @author Satyan Shah <joomlaDesign@modernbridge.com>
 * @link http://www.modernbridge.com
 * @license GNU/GPL
 */


jimport('joomla.application.component.controller');

class spsNewslettersController extends JController
{
	function display()
	{
		// switch based on the controller, default command will be sendNewsletter
		switch(JRequest::getCmd( 'controller', 'sendNewsletter' ))
		{
		
			case 'subscriber':
				// switch based on the task
				switch(JRequest::getVar('task'))
				{
					// if the task requested is add, new, or edit we need to switch in the singular (subscriber sans 's') view.
					case 'add':
					case 'new':
					case 'edit':
						JRequest::setVar( 'view', 'subscriber');
					break;
					// if the task requested is anything else, dump a table of all records in the multiple (subscribers with an 's') view.
					default:
						JRequest::setVar( 'view', 'subscribers');
					break;
				}
      
			break;
      
			
			case 'newsletter':
				// switch based on the task
				switch(JRequest::getVar('task'))
				{
					// if the task requested is add, new, or edit we need to switch in the singular view
					case 'add':
					case 'new':
					case 'edit':
						JRequest::setVar( 'view', 'newsletter');
					break;
					// if the task is anything else, dump a table of all records in multiple view
					default:
						JRequest::setVar( 'view', 'newsletters');
					break;
				} 
      
			break;
     
			
			case 'spsNewsletterConfig':;
				// if the controller selected is spsNewsletter config then set the view / layout appropriately	
				JRequest::setVar( 'view', 'spsNewsletterConfig');
				JRequest::setVar( 'layout', 'form'  );
			break;

        
			default: 
				// if no controller was specified switch in the sendNewsletter view 
				JRequest::setVar( 'view', 'sendNewsletter');
				JRequest::setVar( 'layout', 'form'  );
			break;
		}

		parent::display();
	}

}
?>
